package me.heshang.rednamedrop;

import me.heshang.rednamedrop.Connection.MySql;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.entity.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;;

import java.sql.SQLException;

public class PlayerkilTitle implements Listener {
    public static String PL;
    public static int quantity;
    private static Boolean biologykill;


    @EventHandler
    public void PlayerkilTitle(EntityDeathEvent e) throws SQLException, ClassNotFoundException {
        if ((e.getEntity() instanceof Player)) {
            LivingEntity player = e.getEntity();
            Player p = (Player) e.getEntity();
            PL = p.getKiller().getName();
            p.getKiller().sendMessage(new RedNamedrop().getMessage_redincrease());
            new MySql().change();
            return;
        }else {


            if (biologykill == true) {
                LivingEntity player = e.getEntity();
                try {
                    PL = player.getKiller().getName();
                    if (new MySql().getKillCreature() < quantity) {
                        new MySql().killcreature();
                    } else {
                        player.getKiller().sendMessage(new RedNamedrop().getMessage_redincrease());
                        new MySql().change();
                        new MySql().emptykillcreature();
                    }
                }catch(NullPointerException n){
                }

            }
        }

    }



    public static String getPl() {
        return PL;
    }
    public static void setPl(String pl) {
        PlayerkilTitle.PL = pl;
    }

    public static Boolean getBiologykill() {
        return biologykill;
    }

    public static void setBiologykill(Boolean biologykill) {
        PlayerkilTitle.biologykill = biologykill;
    }

    public static int getQuantity() {
        return quantity;
    }

    public static void setQuantity(int quantity) {
        PlayerkilTitle.quantity = quantity;
    }
}